package com.zjitc;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import javax.sql.DataSource;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/7 14:56
 * @description:
 */
@Configuration
@Import(DataSourceProperties.class)
public class DataSourceConfiguration2 {

    @Bean
    public DataSource dataSource(DataSourceProperties prop) {
        HikariDataSource ds = new HikariDataSource();

        ds.setDriverClassName(prop.getDriverClass());
        ds.setPassword(prop.getPassword());
        ds.setUsername(prop.getUsername());
        ds.setJdbcUrl(prop.getJdbcUrl());

        System.out.println(prop.getNumber());

        return ds;
    }
}
